扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
<summary> /// 插入排序算法 /// </summary> /// <param name="dblArray"></param> static void InsertSort(ref double[] dblArray) { for(int i = 1 ; i < dblArray.Length ; i++) { int frontArrayIndex = i-1 ; int CurrentChangeIndex = i ; while(frontArrayIndex>=0) { if(dblArray[CurrentChangeIndex] < dblArray[frontArrayIndex]) { ChangeValue(ref dblArray[CurrentChangeIndex],ref dblArray[frontArrayIndex]); CurrentChangeIndex = frontArrayIndex ; } frontArrayIndex--; } } } /// <summary> /// 在内存中交换两个数字的值 /// </summary> /// <param name="A"></param> /// <param name="B"></param> static void ChangeValue (ref double A ,ref double B) { double Temp = A ; A = B ; B = Temp ; } |
濡傛灉鎮ㄩ潪甯歌揩鍒囩殑鎯充簡瑙T棰嗗煙鏈€鏂颁骇鍝佷笌鎶€鏈俊鎭紝閭d箞璁㈤槄鑷抽《缃戞妧鏈偖浠跺皢鏄偍鐨勬渶浣抽€斿緞涔嬩竴銆�